package com.lxl.xm.model.vo;

import com.lxl.xm.model.enums.AdTypeEnum;
import com.lxl.xm.service.RevenueService;
import lombok.Data;

import java.io.Serializable;

@Data
public class RevenueVO implements Serializable {
    /**
     * 外键
     */
    private Long adCampaignId;

    /**
     * 广告类型
     */
    private AdTypeEnum adTypeEnum;

    /**
     * 投放时长
     */
    private int duration;

    /**
     * 千次展示收益
     */
    private double cpm;

    /**
     * 单次点击收益
     */
    private double cpc;

    /**
     * 收入
     */
    private double earnings;

    private static final long serialVersionUID = 1L;

    public void calculateTotalEarnings(RevenueService revenueService){
        double performanceRevenue = revenueService.calculatePerformanceRevenue(this.adCampaignId,this.cpm,this.cpc);
        double placementRevenue = revenueService.calculatePlacementRevenue(this.adTypeEnum,this.duration);
        this.earnings = placementRevenue+performanceRevenue;
    }

}
